Xbasic

More about the SQL::Connection Object

Description

While working in the Interactive window, after creating the conn SQL::Connection object, you could type.

? conn

The result would be a long list of methods and properties available to SQL::Connection objects. Here are a few methods and properties that might be of immediate value. For a full description, see SQL::Connection Object. To get a list of tables in the alphasports.mdb database, you would use the SQL::Connection::ListTables() method.

? conn.ListTables()
= Customer
Invoice_Header
Invoice_Items
Product
Salesperson
Vendor

To find out whether the connection was open, you would read the .IsOpen property.

? conn.IsOpen
= .T.

To get the primary key expression for a table, you would use the SQL::Connection::PrimaryKeyExpression() method.

? conn.PrimaryKeyExpression("Customer")
= "CUSTOMER_ID"

To validate the syntax of SELECT statement before sending it to the back-end database, you would use the SQL::Connection::ValidateQuery() method. Note that this method does not find field or table name errors.

dim select_exp as C
select_exp = "select * from customer"
? conn.ValidateQuery(select_exp)
= .T.

Close the connection when you are finished.

conn.close()

Limitations

Desktop applications only.

See Also